import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.key_blue = pygame.image.load("../资源/图片/蓝钥匙.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.sword = pygame.image.load("../资源/图片/青锋剑.png").convert_alpha()
        self.kulou_leader = pygame.image.load("../资源/图片/骷髅队长.png").convert_alpha()
        self.mayi_master = pygame.image.load("../资源/图片/麻衣法师.png").convert_alpha()
        self.red_master = pygame.image.load("../资源/图片/红衣法师.png").convert_alpha()
        self.stone_man = pygame.image.load("../资源/图片/石头怪人.png").convert_alpha()
        self.animal_warrior = pygame.image.load("../资源/图片/兽面武士.png").convert_alpha()

        self.hero_pos = (6, 3)
        self.up_pos = (6, 6)
        self.down_pos = (6, 4)
        self.variable_pos = {
            (1, 2): (self.door_yellow, '黄门'),
            (3, 1): (self.door_yellow, '黄门'),
            (1, 7): (self.door_yellow, '黄门'),
            (3, 10): (self.door_yellow, '黄门'),
            (7, 7): (self.door_yellow, '黄门'),
            (9, 1): (self.door_yellow, '黄门'),
            (9, 9): (self.door_yellow, '黄门'),
            (1, 5): (self.door_blue, '蓝门'),
            (5, 8): (self.door_blue, '蓝门'),
            (3, 4): (self.door_red, '红门'),
            (1, 0): (self.key_yellow, '黄钥匙'),
            (0, 1): (self.key_yellow, '黄钥匙'),
            (10, 2): (self.key_yellow, '黄钥匙'),
            (10, 3): (self.key_yellow, '黄钥匙'),
            (10, 7): (self.key_yellow, '黄钥匙'),
            (10, 8): (self.key_yellow, '黄钥匙'),
            (0, 9): (self.key_blue, '蓝钥匙'),
            (1, 10): (self.key_blue, '蓝钥匙'),
            (1, 8): (self.hp_red, '红药'),
            (2, 9): (self.hp_red, '红药'),
            (10, 4): (self.hp_red, '红药'),
            (10, 6): (self.hp_red, '红药'),
            (4, 10): (self.hp_blue, '蓝药'),
            (6, 10): (self.hp_blue, '蓝药'),
            (0, 6): (self.gem_blue, '蓝宝石'),
            (2, 6): (self.gem_red, '红宝石'),
            (0, 10): (self.sword, '青锋剑'),
            (10, 1): (self.kulou_leader, '骷髅队长'),
            (10, 9): (self.kulou_leader, '骷髅队长'),
            (0, 8): (self.kulou_leader, '骷髅队长'),
            (1, 9): (self.kulou_leader, '骷髅队长'),
            (2, 8): (self.kulou_leader, '骷髅队长'),
            (2, 10): (self.kulou_leader, '骷髅队长'),
            (4, 6): (self.mayi_master, '麻衣法师'),
            (5, 9): (self.mayi_master, '麻衣法师'),
            (1, 6): (self.red_master, '红衣法师'),
            (4, 9): (self.stone_man, '石头怪人'),
            (5, 10): (self.stone_man, '石头怪人'),
            (6, 9): (self.stone_man, '石头怪人'),
            (2, 1): (self.animal_warrior, '兽面武士'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(2, 9):
            self.draw(self.wall, 9, i)
            self.dic[(1, i)] = '墙'
        for i in [(9, 0), (9, 10), (10, 5), (3, 0), (4, 0), (5, 0), (0, 2), (2, 2), (3, 2), (3, 3), (0, 5), (2, 5), (3, 5),
                  (3, 6), (3, 7), (2, 7), (0, 7), (3, 8), (3, 9), (4, 8), (6, 8), (7, 8), (7, 9), (7, 10), (7, 1), (7, 2),
                  (6, 2), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 5), (7, 5), (7, 4), (7, 6)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
